package cn.wen.forum.pojo.doc;

import cn.wen.forum.pojo.entity.Post;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.commons.lang3.StringUtils;

import java.util.ArrayList;
import java.util.List;

/**
 * @ClassName ForumDoc
 * @Author By wen
 * @Description
 * @Date 2023/3/7 16:48
 * @Version 1.0
 */
@Data
@NoArgsConstructor
public class PostDoc {

    private Long id;
    private String title;
    private String userName;
    private String pageView;
    private String review;
    private Integer approval;
    private String content;
    private String flag;
    private boolean elite;
    private boolean top;
    private String timeStr;
    private long time;
    private List<String> suggestion;

    public PostDoc(Post post) {
        this.id = post.getId();
        this.title = post.getTitle();
        this.userName = post.getUserName();
        this.pageView = post.getPageView();
        this.review = post.getReview();
        this.approval = post.getApproval();
        this.content = post.getContent();
        this.flag = post.getFlag();
        if(StringUtils.equals("1",post.getIsElite())){
            this.elite = true;
        } else{
            this.elite = false;
        }
        if(StringUtils.equals("1",post.getIsTop())){
            this.top = true;
        } else{
            this.top = false;
        }
        this.timeStr = post.getTimeStr();
        this.suggestion = new ArrayList<>();
        this.suggestion.add(post.getTitle());
    }
}
